package com.sgb.kjwl.utils;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.GoodsListTypeEntity;

import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
import android.text.TextUtils;

import com.sgb.kjwl.model.entity.enterprise.MakeOverDetailEntity;

import java.util.List;

public class ActivityClassHelper {

    public static MakeOverDetailEntity getDetail(String detailType) {
        MakeOverDetailEntity makeOverDetailEntity = null;
        switch (detailType) {
            case "商标":
                makeOverDetailEntity = new MakeOverDetailEntity("商标详情", "商标详情", "使用范围", "商家信息", "商标分类", "组合类型", "商标注册号", "联系人");
                makeOverDetailEntity.setTitle4("创意说明");
                break;
            case "版权":
                makeOverDetailEntity = new MakeOverDetailEntity("版权详情", "版权详情", "版权简介", "商家信息", "版权分类", "授权方式", "授权期限", "著作权人");
                makeOverDetailEntity.setType5("登记号");
//                makeOverDetailEntity.setType6("作者");
                break;
            case "专利":
                makeOverDetailEntity = new MakeOverDetailEntity("专利详情", "专利详情", "专利说明", "商家信息", "领域分类", "专利类型", "专利注册号", "专利状态");
                makeOverDetailEntity.setType5("申请时间");
                makeOverDetailEntity.setType6("到期时间");
                makeOverDetailEntity.setType7("联系人");
                break;
            case "公司":
                makeOverDetailEntity = new MakeOverDetailEntity("公司详情", "公司详情", "经营范围", "商家信息", "统一社会信用代码", "企业类型", "行业类型", "注册资本");
                makeOverDetailEntity.setTitle4("其他信息");
                makeOverDetailEntity.setType5("成立时间");
                makeOverDetailEntity.setType6("注册地址");
                makeOverDetailEntity.setType7("报税情况");
                makeOverDetailEntity.setType8("纳税规模");
                break;
            case "资产":
                makeOverDetailEntity = new MakeOverDetailEntity("资产详情", "资产详情", "资产简介", "商家信息", "资产类型", "买入时间", "资产新旧", "买入价格");
                break;
        }

        return makeOverDetailEntity;
    }

    public static GoodsListTypeEntity getGoodsListStyle(Context context, int type) {
        GoodsListTypeEntity goodsListTypeEntity = null;
        switch (type) {
            case 0:
                goodsListTypeEntity = new GoodsListTypeEntity(true, true, false, true, R.color.color_main_bg, false, false, DisplayUtil.dip2px(context, 0), DisplayUtil.dip2px(context, 0));
                break;
            case 1:
                goodsListTypeEntity = new GoodsListTypeEntity(false, false, true, true, R.color.color_main_bg, true, false, DisplayUtil.dip2px(context, 0), DisplayUtil.dip2px(context, 0));
                break;
        }

        return goodsListTypeEntity;
    }


    /**
     * 判断某个界面是否在前台
     *
     * @param context   Context
     * @param className 界面的类名
     * @return 是否在前台显示
     */
    public static boolean isForeground(Context context, String className) {
        if (context == null || TextUtils.isEmpty(className))
            return false;
        ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningTaskInfo> list = am.getRunningTasks(1);
        if (list != null && list.size() > 0) {
            ComponentName cpn = list.get(0).topActivity;
            if (className.equals(cpn.getClassName()))
                return true;
        }
        return false;
    }
}
